@echo OFF
:: Check Office Version and Bitness
:: Written by MarkTemple.com
:: Dec 27, 2013
setlocal enableDelayedExpansion
for /f "tokens=2 delims==" %%O in ('ftype ^|findstr /r /I "\\OFFICE[0-9]*" 2^>nul') do (
set "tokens=%%~O"
goto END_TOKENS
)
:END_TOKENS
for %%P in (%tokens%) do (
set "officePath=%%~dpP"
for %%V in ("!officePath:~0,-1!") do (
set "officeVersion=%%~nV"
goto END_OFFICEPATH
)
)
:END_OFFICEPATH
REM Check Office "Version"
if "%officeVersion%" == "Office11" (
echo Microsoft Office 2003
)
if "%officeVersion%" == "Office12" (
echo Microsoft Office 2007
)
if "%officeVersion%" == "Office14" (
echo Microsoft Office 2010
)
if "%officeVersion%" == "Office15" (
echo Microsoft Office 2013
)
if "%officeVersion%" == "" (
echo Microsoft Office is not installed
goto END
)
REM Check Office "Bitness"
set keyName="HKLM\Software\WOW6432Node\Microsoft\Office"
set valueName=""
FOR /F "usebackq skip=4 tokens=1-3" %%A IN (`REG QUERY %keyName%`) DO (
set valueName=%%A
)
if defined valueName (
@echo Microsoft Office is 32-bit
) else (
set keyName="HKLM\Software\Microsoft\Office"
set valueName=""
FOR /F "usebackq skip=4 tokens=1-3" %%A IN (`REG QUERY %keyName%`) DO (
set valueName=%%A
)
if defined valueName (
@echo Microsoft Office is 64-bit
)
)
:END
endlocal
pause